Skip to content

feat(cli): add examples to ao preview --help#388

Merged
harshitsinghbhandari merged 2 commits into
mainfrom
fix/preview-help-examples-387
Jun 22, 2026
Merged

feat(cli): add examples to ao preview --help#388
harshitsinghbhandari merged 2 commits into
mainfrom
fix/preview-help-examples-387

Conversation

@i-trytoohard

Copy link
Copy Markdown
Collaborator

What

Improves ao preview --help with concrete examples for the common workflows.

Closes #387

Changes

  • Added Example field to the preview command — renders an Examples: section in --help with the four common workflows:
    ao preview
    ao preview file://$(pwd)/index.html
    ao preview http://localhost:5173
    ao preview clear
  • Updated Long description — replaced the workspace-relative path (./dist/index.html) with the absolute file:// URL pattern agents actually use.
  • Added test (TestPreview_HelpIncludesExamples) verifying the examples section is present, the file:// example exists, and the old relative-path reference is gone.

Acceptance criteria

Criterion Status
ao preview --help includes a concise examples section
File example uses file://$(pwd)/index.html, not ./index.html
Existing behavior and command syntax unchanged

Test output

=== RUN   TestPreview_WithURLArg              --- PASS
=== RUN   TestPreview_NoArgPostsEmptyURL      --- PASS
=== RUN   TestPreviewClear_DeletesSessionPreview --- PASS
=== RUN   TestPreviewClear_MissingSessionIDIsUsageError --- PASS
=== RUN   TestPreview_MissingSessionIDIsUsageError --- PASS
=== RUN   TestPreview_HelpIncludesExamples    --- PASS
=== RUN   TestPreview_BlankSessionIDIsUsageError --- PASS
PASS

Update the preview command help to include a concise Examples section
covering the four common workflows:

  ao preview
  ao preview file:///home/aoagent/ReverbCode/index.html
  ao preview http://localhost:5173
  ao preview clear

Replace the workspace-relative path (./dist/index.html) in the Long
description with the absolute file:// URL pattern agents actually use.

Command syntax and behavior are unchanged.

Closes #387

@harshitsinghbhandari harshitsinghbhandari left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: #388

Consumer Impact

  • backend/internal/cli/preview.go:26 says bare ao preview “opens the workspace’s index.html.” That is incomplete for the real daemon behavior: setPreview first autodetects a workspace entry, but if none exists it falls back to the session’s existing preview target. There is already a controller test for that fallback: TestSessionsAPI_SetPreviewEmptyURLReusesExistingTargetWhenNoEntryExists. The help text should preserve that nuance while still using the better file://$(pwd)/index.html example.

Suggested wording:

"With no argument it opens the workspace's static entry point, falling back\n" +
"to this session's existing preview target when no entry point exists. A local\n" +
"file can be opened by its absolute file:// URL (e.g. file:///home/me/proj/index.html).\n" +

Boundary Verification

Skipped. The production change is help text only: no new function calls, imports, file I/O, network calls, serialization, schemas, or behavior changes. The boundary risk is the human-facing CLI help contract, covered above.

Testing

I ran:

go test ./internal/cli -run 'TestPreview' -count=1
go test ./internal/cli -count=1
go run ./cmd/ao preview --help
git diff --check origin/main...HEAD

All passed. The rendered help includes the requested ao preview file://$(pwd)/index.html example.

Recommendation

Request Changes

The requested example is good, but the no-argument behavior description regressed from slightly over-specific to still inaccurate in a different way. Fixing that wording should be enough.

Address review feedback on #388: the no-argument description now
reflects the daemon's actual behavior — autodetect the workspace
entry point, fall back to the session's existing preview target
when none exists.
@harshitsinghbhandari harshitsinghbhandari merged commit 82d69ce into main Jun 22, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve ao preview help examples

2 participants